/*
 * This file is part of aKoustiK.

 * aKoustiK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * aKoustiK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with aKoustiK.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef KORE_H
#define KORE_H

#include <KActionCollection>
#include <QtCore/QObject>

#include <player.h>
#include <playlist.h>
#include <tray.h>

class Kore : public QObject {
    Q_OBJECT

private:

    // singleton implementation:
    static Kore* _instance;
    /**
      Kore is singleton, so we should avoid doint anything in constructor. To init actual core there is launch() method.
      */
    Kore();
    ~Kore();
    /** Block copy constructor */
    Kore(const Kore &);
    /** Block 'copy self' operator */
    Kore & operator=(const Kore &);

    // fields:
    KActionCollection *mActionCollection;
    Tray *tray;
    Player *mPlayer;
    Playlist *mPlaylist;

    // init methods:
    /** Method to load the same playlist we had in previous session. */
    void preparePlaylist();
    /** Method to construct and prepare Player.
      Player depends on Playlist, so preparePlaylist()
      must be invoked before this method. */
    void preparePlayer();
    /** Method to prepare global actions.
      It depends on both Playlist and Player, so
      both preparePlaylist() and preparePlayer()
      must be invoked first. */
    void prepareActions();
    /** Method to construct Tray object.
      Tray depends on actions, so prepareActions()
      must be invoked first. */
    void prepareTray();

public:

    // singleton:
    static Kore &instance();

    // methods:
    /** Method responsible for init procedure.
      1. Actions should be prepared because they're used in UI classes.
      2. Tray is always visible.
      */
    void launch();

    // getters:
    KActionCollection* actionCollection();
    Player* player();
    Playlist* playlist();

private slots:
    void removeCurrentItemSignal();
    void playlistChanged();

};

#endif
